{extend name="platform/base" /}
{block name="resources"}
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>
<style>
	.header-title{
		height:30px;
		line-height:30px;
	}
	.left-indent:before{
		content:'';
		display:inline-block;
		width:10%;
	}
	.right-indent:after{
		content:'';
		display:inline-block;
		width:30%;
	}
	.order-count{
		margin-right:20px;
	}
</style>
{/block}

 {block name="main"}
 
<div class="row padder-v">
	<div class="col-sm-3 header-title" >
		<!-- 店铺总营业额：<span id="shop_sale">0</span>&nbsp;&nbsp;&nbsp;&nbsp;平台余额：<span id="platform_money">0</span>&nbsp;&nbsp;&nbsp;&nbsp;店铺余额：<span id="shop_money">0</span> -->
	</div>
	<div class="col-sm-2" >
	    <div class="input-group">
			<input type="text" id="startDate" class="input-sm form-control"placeholder="请选择开始日期" onclick="WdatePicker()" />		
		</div>
	</div>
	<div class="col-sm-2" >
		<div class="input-group">
			<input type="text" id="endDate" placeholder="请选择结束日期" class="input-sm form-control"onclick="WdatePicker()" />
		</div>
	</div>
	<div class="col-sm-2">
		<input type="text" id="search_text" class="input-sm form-control" placeholder="请输入订单号">
	</div>
	<div class="col-sm-2">
		<select id="shop_id" class="input-sm form-control" >
			<option value="">请选择店铺名称</option>
			{foreach name="shoplist" item ="vo"}
			<option value="{$vo.shop_id}">{$vo.shop_name}</option>
			{/foreach}
		</select>
	</div>
	<div class="col-sm-1">
		<button class="btn btn-sm btn-default" type="button"
			onclick="search()">搜索</button>
	</div>
</div>
<section class="panel panel-default">
	<table class="table table-striped b-light text-sm">
		<colgroup>
			<col width="3%">
			<col width="13%">
			<col width="13%">
			<col width="13%">
			<col width="10%">
			<col width="20%">
			<col width="17%">
		</colgroup>
		<thead>
			<tr>
				<th><input type="checkbox"></th>
				<th class="center">订单编号</th>
				<th class="left left-indent">店铺名称</th>
				<th class="right right-indent">实付金额</th>
				<th class="right right-indent">平台获取金额</th>
				<th class="center">下单时间</th>
				<th class="center">是否结算</th>
			</tr>
		</thead>
		<tbody id="list">
			<tr></tr>
		</tbody>
	</table>
	{include file="platform/page" /}
</section>
{/block} {block name="script"}
<script type="text/javascript">

// 交易额与交易量
var order_num,order_money;

$(function(){
	search();
});
/**
 * 查询
 */
function search(){
	LoadingInfo(1);
	getCountInfo();
}
/**
 * 统计信息
 */
function getCountInfo(){
	
	var start_date = $("#startDate").val();
	var end_date = $("#endDate").val();
	var shop_id = $("#shop_id").val();
	$.ajax({
		type : "post",
		url : "{:__URL('PLATFORM_MAIN/statistics/getOrderInfoCount')}",
		async : false,
		data : {
			"start_date":start_date,
			"end_date":end_date,
			"shop_id" : shop_id,
		},
		success : function(data) {
			 order_num = data['order_num'];
			 order_money = data['order_money'];
		}
			
	});
}
	function LoadingInfo(pageIndex) {
		
		var search_text = $("#search_text").val();
		var start_date = $("#startDate").val();
		var end_date = $("#endDate").val();
// 		var user_name = $("#userName").val();
// 		var order_no = $("#orderNo").val();
// 		var order_status = $("#order_status").val();
		var shop_id = $("#shop_id").val();
		
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/statistics/orderStat')}",
			async : true,
			data : {
				"pageIndex" : pageIndex,
				"order_no" : search_text,
				'search_text':search_text,
				"start_date":start_date,
				"end_date":end_date,
				"shop_id" : shop_id,
			},
			success : function(data) {
				//console.log(data);
			    $("#shop_sale").text(data['count']['shop_sale']);
			    $("#platform_money").text(data['count']['platform_money']);
			    $("#shop_money").text(data['count']['shop_money']);
				var html = '';
				$("#total_count_num").text(data['list']["total_count"]);
				$("#page_count_num").text(data['list']["page_count"]);
				$("#page_count").val(data['list']["page_count"]);
				$("#pageNumber a").remove();
				if (data.list["data"].length > 0) {
					for (var i = 0; i < data.list["data"].length; i++) {
						html += '<tr>';
						html += '<td><div class="cell"><label ><input name="sub" type="checkbox" value="'+ data.list["data"][i]["order_no"] +'" ></label></div></td>';
						html += '<td class="center">' + data.list["data"][i]["order_no"] + '</td>';
						html += '<td class="left left-indent">' + data.list["data"][i]["shop_info"]['shop_name'] + '</td>';
						html += '<td class="right right-indent">' + data.list["data"][i]["order_pay_money"] + '</td>';
						html += '<td class="right right-indent">' + data.list["data"][i]["platform_money"] + '</td>';
						html += '<td class="center">' + timeStampTurnTime(data.list["data"][i]["create_time"]) + '</td>';
						if(data.list["data"][i]["is_issue"]){
							html += '<td class="center"><i class="fa fa-check text-success"></i></td>';
						}else{
							html += '<td class="center"><i class="fa  fa-times"></i></td>';
						}																												
						
						html += '</tr>';
					}
					
					html += '<tr>';
						html += '<td colspan="8" class="right">';
							html += '<span class="order-count">总交易额：'+ order_money +'元</span>';
							html += '<span class="order-count">总交易量：'+ order_num +'</span>';
						html += '</td>';
					html += '</tr>';
			
				} else {
					html += '<tr align="center"><td colspan="8">暂无订单统计记录数据</td></tr>';
				}
				$("#list").html(html);
				var totalpage = $("#page_count").val();
				if (totalpage == 1) {
					changeClass("all");
				}
				var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
				$("#pageNumber").append($html);
			}
		});
	}
	$("#search_text").keypress(function(e){
		if(e.keyCode == 13){
			LoadingInfo(1);
		}
	});
</script>
{/block}
